package ylsb.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Controller
public class PageController {

    @RequestMapping("main/jindu")
    public String jindu(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            String mmXiangmuleixing = request.getParameter("xiangmuleixing").toString();
            map.put("xiangmuId", mmXiangmuId);
            map.put("xiangmuLeixing", mmXiangmuleixing);
            return "main/list_jindu";
        } else {
            return "main/login";
        }

    }

    @RequestMapping("main/login")
    public String Login(HttpServletRequest request) {

        return "main/login";

    }

    @RequestMapping("main/xiangmu")
    public String Listxiangmu(HttpServletRequest request) {

        if (isLogin(request)) {
            return "main/list_xiangmu";
        } else {
            return "main/login";
        }

    }
    @RequestMapping("main/renyuan")
    public String Listrenyuan(HttpServletRequest request) {

        if (isLogin(request)) {
            return "main/list_renyuan";
        } else {
            return "main/login";
        }

    }
    @RequestMapping("main/renyuanfenpei")
    public String renyuanfenpei(HttpServletRequest request) {

        if (isLogin(request)) {
            return "main/List_renyuanfenpei";
        } else {
            return "main/login";
        }

    }

    @RequestMapping("main/baofei")
    public String Listbaofei(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_baofei";
        } else {
            return "main/login";
        }

    }

    @RequestMapping("main/dailiangchuangxin")
    public String Listdailiangchuangxin(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_dailiangchuangxin";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/shiji")
    public String Listshiji(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_shiji";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/hc2")
    public String Listhc2(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_hc2";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/hc1")
    public String Listhc1(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_hc1";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/hc3")
    public String Listhc3(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_hc3";
        } else {
            return "main/login";
        }
    }

    @RequestMapping("main/hc45")
    public String Listhc45(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_hc45";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/hc5")
    public String Listhc5(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_hc5";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/yuxuanhui")
    public String Listyuxuanhui(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_yuxuanhui";
        } else {
            return "main/login";
        }
    }

    //设备
    @RequestMapping("main/shebei")
    public String Listshebei(HttpServletRequest request, ModelMap map) {
        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_shebei";
        } else {
            return "main/login";
        }
    }

    @RequestMapping("main/yinjin")
    public String Listyinjin(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_yinjin";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/haocaiyinjin")
    public String Listhaocaiyinjin(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_haocaiyinjin";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/yiyonghaocai")
    public String ListYiyonghaocai(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_yiyonghaocai";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/tiwaizhenduan")
    public String Listtiwaizhenduan(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_tiwaizhenduan";
        } else {
            return "main/login";
        }
    }

    @RequestMapping("main/haocaiduibiao")
    public String Listhaocaiduibiao(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_haocaiduibiao";
        } else {
            return "main/login";
        }

    }

    @RequestMapping("main/zhuankeyinjin")
    public String Listzhuankeyinjin(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_zhuankeyinjin";
        } else {
            return "main/login";
        }

    }

    @RequestMapping("main/print")
    public String print(HttpServletRequest request, ModelMap map) {
        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            String mmXiangmuleixing = request.getParameter("xiangmuleixing").toString();
            map.put("xiangmuId", mmXiangmuId);
            map.put("xiangmuLeixing", mmXiangmuleixing);
            return "main/list_print";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/printYiyonghaocai")
    public String printYiyonghaocai(HttpServletRequest request, ModelMap map) {
        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            String mmXiangmuleixing = request.getParameter("xiangmuleixing").toString();
            map.put("xiangmuId", mmXiangmuId);
            map.put("xiangmuLeixing", mmXiangmuleixing);
            return "main/list_print_yiyonghaocai";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("main/printHaocaiyinjin")
    public String printHaocaiyinjin(HttpServletRequest request, ModelMap map) {
        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            String mmXiangmuleixing = request.getParameter("xiangmuleixing").toString();
            map.put("xiangmuId", mmXiangmuId);
            map.put("xiangmuLeixing", mmXiangmuleixing);
            return "main/list_print_haocaiyinjin";
        } else {
            return "main/login";
        }
    }

    @RequestMapping("main/printTiwaizhenduan")
    public String printTiwaizhenduan(HttpServletRequest request, ModelMap map) {
        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            String mmXiangmuleixing = request.getParameter("xiangmuleixing").toString();
            map.put("xiangmuId", mmXiangmuId);
            map.put("xiangmuLeixing", mmXiangmuleixing);
            return "main/list_print_tiwaizhenduan";
        } else {
            return "main/login";
        }
    }

    @RequestMapping("main/yiyonghuizongbiao")
    public String yuecaihuizongbiao(HttpServletRequest request,ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_yiyonghuizongbiao";
        } else {
            return "main/login";
        }

    }

    @RequestMapping("main/shijihuizongbiao")
    public String shijihuizongbiao(HttpServletRequest request,ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            map.put("xiangmuId", mmXiangmuId);
            return "main/list_shijihuizongbiao";
        } else {
            return "main/login";
        }

    }

    @RequestMapping("main/printDailiangchuangxin")
    public String printDailiangchuangxin(HttpServletRequest request, ModelMap map) {
        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            String mmXiangmuleixing = request.getParameter("xiangmuleixing").toString();
            map.put("xiangmuId", mmXiangmuId);
            map.put("xiangmuLeixing", mmXiangmuleixing);
            return "main/list_print_Dailiangchuangxin";
        } else {
            return "main/login";
        }
    }

    @RequestMapping("main/printShiji")
    public String printShiji(HttpServletRequest request, ModelMap map) {
        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            String mmXiangmuleixing = request.getParameter("xiangmuleixing").toString();
            map.put("xiangmuId", mmXiangmuId);
            map.put("xiangmuLeixing", mmXiangmuleixing);
            return "main/list_print_shiji";
        } else {
            return "main/login";
        }
    }

    @RequestMapping("vote/xiangmu")
    public String votexiangmu(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            HttpSession session = request.getSession();
            String mmUserid=session.getAttribute("Id").toString();
            return "vote/list_xiangmu_vote";

        } else {
            return "main/login";
        }
    }
    @RequestMapping("vote/vote")
    public String vote(HttpServletRequest request, ModelMap map) {

        if (isLogin(request)) {
            String mmXiangmuId = request.getParameter("xiangmuid").toString();
            String mmXiangmuleixing = request.getParameter("xiangmuleixing").toString();
            map.put("xiangmuId", mmXiangmuId);
            map.put("xiangmuleixing", mmXiangmuleixing);

            if("12".equals(mmXiangmuleixing)){
                return "vote/list_shebei_vote";
            }
            if("13".equals(mmXiangmuleixing)){
                return "list_hc23_vote";
            }
            if("14".equals(mmXiangmuleixing)){
                return "vote/list_hc3_vote";
            }
            if("15".equals(mmXiangmuleixing)){
                return "vote/list_hc45_vote";
            }
            if("16".equals(mmXiangmuleixing)){
                return "vote/list_hc45_vote";
            }
            if("17".equals(mmXiangmuleixing)){
                return "vote/list_hc45_vote";
            }
            if("18".equals(mmXiangmuleixing)){
                return "vote/list_hc1_vote";
            }
            if("19".equals(mmXiangmuleixing)||"20".equals(mmXiangmuleixing)){
                return "vote/list_hc23_vote";
            }
            if("21".equals(mmXiangmuleixing)||"22".equals(mmXiangmuleixing)){
                return "vote/list_hc45_vote";
            }
            if("23".equals(mmXiangmuleixing)){
                return "vote/list_hc1_vote";
            }
            if("24".equals(mmXiangmuleixing)){
                return "vote/list_hc45_vote";
            }
            if("25".equals(mmXiangmuleixing)||"27".equals(mmXiangmuleixing)){
                return "vote/list_hc45_vote";
            }
            if("26".equals(mmXiangmuleixing)||"28".equals(mmXiangmuleixing)){
                return "vote/list_hc45_vote";
            }
            if("29".equals(mmXiangmuleixing)){
                return "vote/list_hc45_vote";
            }
            if("1".equals(mmXiangmuleixing)){
                return "vote/list_yinjin_vote";
            }
            if("2".equals(mmXiangmuleixing)){
                return "vote/list_baofei_vote";
            }
            if("7".equals(mmXiangmuleixing)){
                return "vote/list_yiyonghaocai_vote";
            }
            if("8".equals(mmXiangmuleixing)){
                return "vote/list_dailiangchuangxin_vote";
            }
            if("9".equals(mmXiangmuleixing)){
                return "vote/list_dailiangchuangxin_vote";
            }
            if("10".equals(mmXiangmuleixing)){
                return "vote/list_shiji_vote";
            }
            if("11".equals(mmXiangmuleixing)){
                return "vote/list_shiji_vote";
            }

            return "main/login";
        } else {
            return "main/login";
        }
    }

    @RequestMapping("vote/baofei")
    public String votebaofei(HttpServletRequest request) {

        if (isLogin(request)) {
            return "vote/list_baofei_vote";
        } else {
            return "main/login";
        }

    }
    @RequestMapping("vote/yinjin")
    public String voteyinjin(HttpServletRequest request) {

        if (isLogin(request)) {
            return "vote/list_yinjin_vote";
        } else {
            return "main/login";
        }
    }
    @RequestMapping("vote/haocaiyinjin")
    public String votehaocaiyinjin(HttpServletRequest request) {

        if (isLogin(request)) {
            return "vote/list_haocaiyinjin_vote";
        } else {
            return "main/login";
        }

    }
    @RequestMapping("vote/yiyonghaocai")
    public String voteyiyonghaocai(HttpServletRequest request) {

        if (isLogin(request)) {
            return "vote/list_yiyonghaocai_vote";
        } else {
            return "main/login";
        }

    }
    @RequestMapping("vote/tiwaizhenduan")
    public String votetiwaizhenduan(HttpServletRequest request) {

        if (isLogin(request)) {
            return "vote/list_tiwaizhenduan_vote";
        } else {
            return "main/login";
        }

    }



    @RequestMapping("vote/haocaiduibiao")
    public String votehaocaiduibiao(HttpServletRequest request) {

        if (isLogin(request)) {
            return "vote/list_haocaiduibiao_vote";
        } else {
            return "main/login";
        }

    }
    @RequestMapping("vote/zhuankeyinjin")
    public String votezhuankeyinjin(HttpServletRequest request) {

        if (isLogin(request)) {
            return "vote/list_zhuankeyinjin_vote";
        } else {
            return "main/login";
        }

    }
    //上传
    @RequestMapping("main/upload_batch.html")
    public String UploadBatch(ModelMap map, HttpServletRequest request) {

        if(!isLogin(request)) {
            return "redirect:/main/login.html";
        }

        String mmFuJianPath = request.getParameter("fujianpath").toString();
        String mmFileSize = request.getParameter("filesize").toString();
        map.put("filetype", "batch");
        map.put("fujianpath", mmFuJianPath);
        map.put("filesize", mmFileSize);
        return "main/UploadBatch";
    }




    public boolean isLogin(HttpServletRequest request) {
        HttpSession session = request.getSession();
        if (session == null || session.getAttribute("Id") == null) {
            return false;
        }
        return true;
    }

}
